#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/device.h>
int xdrv_probe(struct device *dev)
{
    printk("xdrv probe\n");
    dev->driver->probe(dev);
    return 0;
}
int xdrv_remove(struct device *dev)
{
    printk("xdev remove\n");
    return 0;
}
extern struct bus_type xbus;
struct device_driver xdrv = {
    .name = "wangcai",
    .bus = &xbus,
    .probe = xdrv_probe,
    .remove = xdrv_remove,
};

int test_init(void)
{
    int ret = driver_register(&xdrv);
    if (ret < 0)
    {
        printk("driver register is error\n");
        return -1;
    }
    printk("insmod xdrv\n");
    return 0;
}
void test_exit(void)
{
    driver_unregister(&xdrv);
    printk("rmmod xdrv\n");
}
MODULE_LICENSE("GPL");
module_init(test_init);
module_exit(test_exit);